<!DOCTYPE HTML>
<html lang="en">
<head>
<title>Func Object - Methods &amp; Properties | AutoHotkey</title>
<meta name="description" content="The Func object provides an interface for a function to retrieve values, such as the number of parameters, or to perform actions, such as calling." />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="../static/theme.css" rel="stylesheet" type="text/css" />
<script src="../static/content.js" type="text/javascript"></script>
</head>
<body>

<h1>Func Object <span class="ver">[v1.1.00+]</span></h1>

<p>Represents a user-defined or built-in function which can be called by the script. <a href="../commands/Func.htm">Func</a> returns an object of this type.</p>

<p>For information about other objects which can be called like functions, see <a href="Functor.htm">Function Objects</a>.</p>

<p>A reference to a Func object is also known as a <em>function reference</em>. To retrieve a function reference, use the Func function as in the following example:</p>
<pre><em>; Retrieve a reference to the function named "StrLen".</em>
fn := Func("StrLen")

<em>; Display information about the function.</em>
MsgBox % fn.Name "() is " (fn.IsBuiltIn ? "built-in." : "user-defined.")</pre>

<h2 id="Members">Object Members</h2>
<p><strong>Properties:</strong></p>
<ul>
  <li><a href="#Name">Name</a>: Returns the function's name.</li>
  <li><a href="#IsBuiltIn">IsBuiltIn</a>: Returns <i>true</i> if the function is <a href="../Functions.htm#BuiltIn">built-in</a> and <i>false</i> otherwise.</li>
  <li><a href="#IsVariadic">IsVariadic</a>: Returns <i>true</i> if the function is <a href="../Functions.htm#Variadic">variadic</a> and <i>false</i> otherwise.</li>
  <li><a href="#MinParams">MinParams</a>: Returns the number of required parameters.</li>
  <li><a href="#MaxParams">MaxParams</a>: Returns the number of formally-declared parameters for a user-defined function or maximum parameters for a built-in function.</li>
</ul>
<p><strong>Methods:</strong></p>
<ul>
  <li><a href="#Call">Call</a>: Calls the function.</li>
  <li><a href="#Bind">Bind</a>: Binds parameters to the function and returns a <a href="Functor.htm#BoundFunc">BoundFunc object</a>.</li>
  <li><a href="#IsByRef">IsByRef</a>: Determines whether a parameter is ByRef.</li>
  <li><a href="#IsOptional">IsOptional</a>: Determines whether a parameter is optional.</li>
</ul>

<div class="methodShort" id="Call"><h2>Call</h2>
<p>Calls the function.</p>
<pre class="Syntax">
Func.<span class="func">Call</span>(Param1, Param2, ...)  <em>; Requires <span class="ver">[v1.1.19+]</span></em>
Func.(Param1, Param2, ...)  <em>; Old form - deprecated</em>
</pre>
<dl>
  <dt>Param1, Param2, ...</dt>
  <dd>Parameters and return value are defined by the function.</dd>
</dl>
<p><span class="ver">[v1.1.07+]:</span> <code><a href="../Functions.htm#DynCall">%Func%()</a></code> can be used to call a function by name or reference, or to call an object which implements the __Call <a href="../Objects.htm#Meta_Functions">meta-function</a>. This should be used instead of <code>Func.()</code> wherever possible.</p>
</div>

<div class="methodShort" id="Bind"><h2>Bind <span class="ver">[v1.1.20+]</span></h2>
<p>Binds parameters to the function and returns a <a href="Functor.htm#BoundFunc">BoundFunc object</a>.</p>
<pre class="Syntax">BoundFunc := Func.<span class="func">Bind</span>(Param1, Param2, ...)</pre>
<dl>
  <dt>Param1, Param2, ...</dt>
  <dd>Any number of parameters.</dd>
</dl>
<p>For details and examples, see <a href="Functor.htm#BoundFunc">BoundFunc object</a>.</p>
</div>

<div class="methodShort" id="Name"><h2>Name</h2>
<p>Returns the function's name.</p>
<pre class="Syntax">FunctionName := Func.Name</pre>
</div>

<div class="methodShort" id="IsBuiltIn"><h2>IsBuiltIn</h2>
<p>Returns <i>true</i> if the function is <a href="../Functions.htm#BuiltIn">built-in</a> and <i>false</i> otherwise.</p>
<pre class="Syntax">Boolean := Func.IsBuiltIn</pre>
</div>

<div class="methodShort" id="IsVariadic"><h2>IsVariadic</h2>
<p>Returns <i>true</i> if the function is <a href="../Functions.htm#Variadic">variadic</a> and <i>false</i> otherwise.</p>
<pre class="Syntax">Boolean := Func.IsVariadic</pre>
</div>

<div class="methodShort" id="MinParams"><h2>MinParams</h2>
<p>Returns the number of required parameters.</p>
<pre class="Syntax">ParamCount := Func.MinParams</pre>
</div>

<div class="methodShort" id="MaxParams"><h2>MaxParams</h2>
<p>Returns the number of formally-declared parameters for a user-defined function or maximum parameters for a built-in function.</p>
<pre class="Syntax">ParamCount := Func.MaxParams</pre>
<p>If the function is <a href="../Functions.htm#Variadic">variadic</a>, <em>ParamCount</em> indicates the maximum number of parameters which can be accepted by the function without overflowing into the "variadic*" parameter.</p></div>

<div class="methodShort" id="IsByRef"><h2>IsByRef</h2>
<p>Determines whether a parameter is ByRef.</p>
<pre class="Syntax">Boolean := Func.<span class="func">IsByRef</span>(<span class="optional">ParamIndex</span>)</pre>
<dl>
  <dt>ParamIndex</dt>
  <dd>Optional: the one-based index of a parameter. If omitted, <em>Boolean</em> indicates whether the function has any ByRef parameters.</dd>
</dl>
<p><strong>Returns</strong> an empty string if the function is built-in or <i>ParamIndex</i> is invalid; otherwise, a boolean value indicating whether the parameter is ByRef.</p>
</div>

<div class="methodShort" id="IsOptional"><h2>IsOptional</h2>
<p>Determines whether a parameter is optional.</p>
<pre class="Syntax">Boolean := Func.<span class="func">IsOptional</span>(<span class="optional">ParamIndex</span>)</pre>
<dl>
  <dt>ParamIndex</dt>
  <dd>Optional: the one-based index of a parameter. If omitted, <em>Boolean</em> indicates whether the function has any optional parameters.</dd>
</dl>
<p><strong>Returns</strong> an empty string if <i>ParamIndex</i> is invalid; otherwise, a boolean value indicating whether the parameter is optional.</p>
<p>Parameters do not need to be formally declared if the function is variadic. Built-in functions are supported.</p></div>

</body>
</html>
